{$CLEO .cs}
0000:
 

model.Load(#STREAK)
model.Load(#STREAKC)
load_requested_models

:loop
const
    train_stopped = 10@ 

end 
train_stopped=0 
:1
wait 0
if and 
model.Available(#STREAK)
model.Available(#STREAKC)
jf @1 
 
//actor.StorePos( player1, 22@,23@,24@)
repeat 
wait 0 
until 33@ >  20000
04C4: store_coords_to 22@ 23@ 24@ from_actor player1 with_offset 60.0 60.0 0.0
06D8: 0@ = create_train_at  22@ 23@ 24@ type 16 direction 1
06DC: set_train 0@ acc 60.0
06DD: set_train 0@ speed 60.0
 1@ = marker.CreateAboveCar(0@)
 marker.SetColor(1@, 4)
 marker.SetIconSize(1@,2)
018B: set_marker 1@ radar_mode 2
33@=0 
    while true 
    wait 0
        if is_car_defined 0@ 
        then 
                if train_stopped==0
                then
                    if or 
                     01AF:   car 0@ sphere 0 in_sphere  -456.6826 -4437.9531 4.9662 radius 6.3 6.3 3.0
                     01AF:   car 0@ sphere 0 in_sphere -3945.3315 -6119.2861 16.8353  radius 6.3 6.3 3.0
                     01AF:   car 0@ sphere 0 in_sphere -3082.8687 -4006.6772 24.3862  radius 6.3 6.3 3.0
                     01AF:   car 0@ sphere 0 in_sphere -3063.6467 -3997.9824 24.3862  radius 6.3 6.3 3.0
                     01AF:   car 0@ sphere 0 in_sphere -3416.6235 -2364.6602 24.3862  radius 6.3 6.3 3.0
                     01AF:   car 0@ sphere 0 in_sphere -3445.5122 -2396.7639 24.3862  radius 6.3 6.3 3.0
                     01AF:   car 0@ sphere 0 in_sphere  -4446.6768 -1600.9254 24.3928 radius 6.3 6.3 3.0
                    

                    then
                        train_stopped=1
                        gosub @slow_stop_train 
                    end
                    if or 
                     01AF:   car 0@ sphere 0 in_sphere   -454.9391 -3148.9839 4.4562 radius 6.3 6.3 3.0
                     01AF:   car 0@ sphere 0 in_sphere  -1782.2487 -4751.8213 24.3862 radius 6.3 6.3 3.0
                     01AF:   car 0@ sphere 0 in_sphere -1268.0254 -5437.541 25.3298 radius 6.3 6.3 3.0
     

                    then
                        train_stopped=1
                        gosub @stop_train 
                    end
               end     
               {
                 or
                  01AF:   car 0@ sphere 0 in_sphere  -1710.9052 -4754.1011 24.3862 radius 2.3 2.3 3.0
                  01AF:   car 0@ sphere 0 in_sphere -393.6799 -3154.7014 4.4562  radius 2.3 2.3 3.0
                  01AF:   car 0@ sphere 0 in_sphere -458.9049 -4494.7681 4.9662  radius 2.3 2.3 3.0
                  01AF:   car 0@ sphere 0 in_sphere  -1282.1602 -5435.0381 24.3862 radius 2.3 2.3 3.0


                  01AF:   car 0@ sphere 0 in_sphere  -1240.9048 -5439.3286 24.3862 radius 2.3 2.3 3.0
                  01AF:   car 0@ sphere 0 in_sphere   radius 2.3 2.3 3.0
                  01AF:   car 0@ sphere 0 in_sphere   radius 2.3 2.3 3.0
                  01AF:   car 0@ sphere 0 in_sphere   radius 2.3 2.3 3.0

                                                                                   }
                 if and
                 train_stopped==1
                  32@ >= 10000
                 then
                    train_stopped=0
                    wait 200
                    06DC: set_train 0@ acc 10.0
                    06DD: set_train 0@ speed 10.0
                    wait 200
                    06DC: set_train 0@ acc 20.0
                    06DD: set_train 0@ speed 20.0
                    wait 200
                    06DC: set_train 0@ acc 30.0
                    06DD: set_train 0@ speed 30.0
                    wait 200
                    06DC: set_train 0@ acc 40.0
                    06DD: set_train 0@ speed 40.0
                    wait 200
                    06DC: set_train 0@ acc 50.0
                    06DD: set_train 0@ speed 50.0
                    wait 200
                    06DC: set_train 0@ acc 60.0
                    06DD: set_train 0@ speed 60.0
                    32@ = 0 
                    
                 end  
        end
        
        if 8205:  not  actor $PLAYER_ACTOR near_car  0@  radius 100.0 100.0 100.0 flag 0

        then
              show_text_box "Train will now disappear..."
            model.Destroy(#STREAK)
            model.Destroy(#STREAKC)
        
           if is_car_defined 0@
           then
            
              07BE: remove_references_to_train 0@

           end
           jump @loop
           terminate_this_custom_script
        end 
    end
0A93: 

:stop_train
    wait 200
    06DC: set_train 0@ acc 50.0
    06DD: set_train 0@ speed 40.0
    wait 200
    06DC: set_train 0@ acc 40.0
    06DD: set_train 0@ speed 40.0
    
    wait 200
    06DC: set_train 0@ acc 30.0
    06DD: set_train 0@ speed 30.0
    wait 200
    06DC: set_train 0@ acc 20.0
    06DD: set_train 0@ speed 20.0
    wait 200
    06DC: set_train 0@ acc 10.0
    06DD: set_train 0@ speed 10.0
    wait 200
    06DC: set_train 0@ acc 0.0
    06DD: set_train 0@ speed 0.0
    32@=0 
 
return  
:slow_stop_train
    wait 500
    06DC: set_train 0@ acc 50.0
    06DD: set_train 0@ speed 40.0
    wait 500
    06DC: set_train 0@ acc 40.0
    06DD: set_train 0@ speed 40.0
    
    wait 500
    06DC: set_train 0@ acc 30.0
    06DD: set_train 0@ speed 30.0
    wait 500
    06DC: set_train 0@ acc 20.0
    06DD: set_train 0@ speed 20.0
    wait 500
    06DC: set_train 0@ acc 10.0
    06DD: set_train 0@ speed 10.0
    wait 500
    06DC: set_train 0@ acc 0.0
    06DD: set_train 0@ speed 0.0
    32@=0 
    
return  
 